package com.gx.server.controller;

import com.gx.server.common.BaseResponse;
import com.gx.server.common.ErrorCode;
import com.gx.server.common.ResultUtils;
import com.gx.server.model.domain.ExamErrors;
import com.gx.server.model.domain.ExamQuestion;
import com.gx.server.model.service.ExamErrorsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Dobby
 * @version 1.0
 */
@RestController
@RequestMapping("/ExamErrors")
@Slf4j
public class ExamErrorsController {

    @Autowired
    ExamErrorsService examErrorsService;

    /**
     * 将正确的题目进行权重下降
     * @param id
     * @param examQuestions 交卷后正确的题目集合
     * @return
     */
    @PutMapping("/drop")
    public void weight_drop(Long id,@RequestBody List<ExamQuestion> examQuestions){
        System.out.println("examQuestions----");
        System.out.println(examQuestions.size());
        examErrorsService.weight_drop(id,examQuestions);
    }




    /**
     * 将错误的题目进行权重的上升
     * @param id
     * @param examQuestions 交卷后错误的题目集合
     * @return
     */
    @PutMapping("/rise")
    public void Weight_rise(Long id, @RequestBody List<ExamQuestion> examQuestions){
        examErrorsService.Weight_rise(id,examQuestions);
    }


    /**
     * 根据用户id 题目id 删除错题库里面的数据
     * @param id
     * @return
     */
    @DeleteMapping("/del")
    public BaseResponse<String> del_Errors(Long id,int questuinId){
        String s = examErrorsService.del_Errors(id, questuinId);
        return ResultUtils.success(s);
    }


}
